package my;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;

public class QQMainFrame {

	public static void main(String[] args) {
		start(null);
	}

	public static void start(String user) {
		JFrame frame = new JFrame("主界面");
		frame.setBounds(1500, 0, 300, 900);

		JPanel mainPanel = new JPanel();
		//mainPanel.setBorder(new LineBorder(Color.BLACK,5));
		frame.setContentPane(mainPanel);

		JPanel myInfoPanel = new JPanel();
		myInfoPanel.setBounds(5, 10, 275, 100);
		ImageIcon ii = new ImageIcon("F:\\QQImgs\\1.jpg");
		JLabel label = new JLabel(ii);
		label.setBounds(3, 3, ii.getIconWidth(), ii.getIconHeight());
		myInfoPanel.add(label);
		JLabel label2 = new JLabel("往事随风");
		Font font = new Font("宋体", Font.PLAIN, 25);
		label2.setFont(font);
		label2.setBounds(105, 30, 100, 30);
		myInfoPanel.add(label2);
		//myInfoPanel.setBorder(new LineBorder(Color.RED));
		myInfoPanel.setLayout(null);
		mainPanel.add(myInfoPanel);

		JPanel addFriendsPanel = new JPanel();
		addFriendsPanel.setBounds(5, 110, 275, 50);
		JTextField searchTxt = new JTextField(12);
		searchTxt.setFont(font);
		addFriendsPanel.add(searchTxt);
		JButton addBtn = new JButton("添加");
		addBtn.setFont(font);
		addBtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				String friend = searchTxt.getText();
				QQClient.addFriend(user,friend);
			}
		});
		addFriendsPanel.add(addBtn);
		//addFriendsPanel.setBorder(new LineBorder(Color.RED));
		mainPanel.add(addFriendsPanel);

		JPanel friendsPanel = new JPanel();
		friendsPanel.setBounds(5, 60, 275, 450);
		JLabel label1 = new JLabel("好友信息：");
		friendsPanel.add(label1);
		//friendsPanel.setBorder(new LineBorder(Color.RED));
		mainPanel.add(friendsPanel);

		frame.setLayout(null);//不使用系统布局方式
		//frame.setLayout(new FlowLayout());//流式布局
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//关闭窗体退出程序
		frame.setVisible(true);
	}

}
